package com.qr.read;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;

import java.io.FileInputStream;

public class ReadTest {

    String path = "E:\\workspace\\GitRepository\\java-framework\\poi\\poi-use\\src\\main\\resources";

    @Test
    public void test07() throws Exception{

        //获取文件流
        FileInputStream fileInputStream = new FileInputStream(path+"信息统计07版本.xlsx");

        XSSFWorkbook sheets = new XSSFWorkbook(fileInputStream);
        //得到这一行，通过下标来获取
        Sheet sheetAt = sheets.getSheetAt(0);
        //得到第一行数据
        Row row1 = sheetAt.getRow(0);
        //得到第一行下第一列的数据
        Cell cell = row1.getCell(0);
        //得到里面的数据,这个获取的是字符串
        /**
         * 值得读取需要对应类型
         */
        //字符串不能使用double来接收
//        double numericCellValue = cell.getNumericCellValue();
        String stringCellValue = cell.getStringCellValue();
        System.out.println(stringCellValue);
        fileInputStream.close();

    }
}
